<template>
  <div class="admin">
    <div class="title">{{title}}</div>
    <div class="status">
      <el-select v-model="value" placeholder="请选择" @change="goToLogin">
        <el-option v-for="(item,index) in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
      </el-select>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'Admin',
    data () {
      return {
        title:'小红果洗车',
        options: [{
          value: 'admin',
          label: '',
        },{
          value: 'zhuxiao',
          label: '注销',
        }],
        value: '',
        phoneNumber: '',//手机号
      }
    },
    mounted() {
      this.getloginData();
    },
    methods:{
      //判断token
      getloginData(){
      	// 获取缓存token信息
        this.token = localStorage.getItem('token');
        this.phoneNumber = localStorage.getItem('phoneNumber');
        // console.log(this.token,"获取缓存token信息")
      	if(this.token){
          this.value = "账户 ："+this.phoneNumber;
          this.options[0].label = "账户 ："+this.phoneNumber;
      	}else{
          this.$router.push({
            path: '/Login',
          })
      	}
      },
      // 点击注销跳转
      goToLogin(vId){
        if(vId== 'zhuxiao'){
          // console.log("注销");
          localStorage.removeItem('token'); //移除token缓存数据
          this.$router.push({
            path: '/Login',
          })
        }
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
  .admin{
    width: 100%;
    height: 50px;
    background-color: rgba(255,255,255,1);
    z-index: 1001;
    display: flex;
    flex-direction: row;
    justify-content:space-between;
    .title{
      line-height: 50px;
      padding-left: 50px;
    }
    .status{
      margin: 0 20px;
      >>> .el-input input{
        margin: 5px 0;
      }
      >>> .el-popper{
        width: 217px;
      }
      >>> .el-cascader-menu{
        min-width: 217px;
      }
      >>> .el-cascader-menu__wrap{
        height: 100px!important;
      }
    }
  }
  .el-select-dropdown__item.selected{
    color: #333;
  }
</style>
